#ifndef __INCLUDED_CBL_DELEGATE_H__
#error "CBL_Delegate.hpp must not be used directly. Use CBL_Delegate.h instead."
#else
#ifndef __INCLUDED_CBL_DELEGATE_HPP__
#define __INCLUDED_CBL_DELEGATE_HPP__

// -------------------------------------------------------------------------------------------------
//	CDelegate
// -------------------------------------------------------------------------------------------------

template <typename TClass, void (TClass::*TMethod)()>
CB_FORCEINLINE CDelegate CB_INLINE_ATTR CDelegate::Create(TClass* _pObject)
{
    CDelegate Delegate(_pObject);
    Delegate.m_pFunctionPointer = &ObjectFunction<TClass,TMethod>;
    return Delegate;
}

// -------------------------------------------------------------------------------------------------

CB_FORCEINLINE void CB_INLINE_ATTR CDelegate::operator()()
{
    m_pFunctionPointer(m_pObject);
}

// -------------------------------------------------------------------------------------------------

template <typename TClass, void (TClass::*TMethod)()>
CB_FORCEINLINE void CB_INLINE_ATTR CDelegate::ObjectFunction(void* _pObject)
{
    (static_cast<TClass*>(_pObject)->*TMethod)();
}

// -------------------------------------------------------------------------------------------------
//	CInOutDelegate
// -------------------------------------------------------------------------------------------------

template <typename TClass, void (TClass::*TMethod)(void*)>
CB_FORCEINLINE CInOutDelegate CB_INLINE_ATTR CInOutDelegate::Create(TClass* _pObject)
{
    CInOutDelegate Delegate(_pObject);
    Delegate.m_pFunctionPointer = &ObjectFunction<TClass,TMethod>;
    return Delegate;
}

// -------------------------------------------------------------------------------------------------

CB_FORCEINLINE void CB_INLINE_ATTR CInOutDelegate::operator()(void* _pInOut)
{
	m_pFunctionPointer(m_pObject, _pInOut);
}

// -------------------------------------------------------------------------------------------------

template <typename TClass, void (TClass::*TMethod)(void*)>
CB_FORCEINLINE void CB_INLINE_ATTR CInOutDelegate::ObjectFunction(void* _pObject, void* _pInOut)
{
    (static_cast<TClass*>(_pObject)->*TMethod)(_pInOut);
}

#endif
#endif